﻿<UserControl
    x:Class="UsingBxfNav.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:my="clr-namespace:UsingBxfNav.ViewModels" 
    xmlns:myx="clr-namespace:UsingBxfNav.Xaml"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" xmlns:bxf="http://schemas.lhotka.net/1.0.0/bxf">
  <UserControl.Resources>
    <my:MainPageViewModel x:Key="viewmodel"/>
  </UserControl.Resources>
  <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootGridStyle}"  DataContext="{StaticResource viewmodel}">

    <Border x:Name="ContentBorder" Style="{StaticResource ContentBorderStyle}">
      <Grid>
        <navigation:Frame x:Name="ContentFrame" Style="{StaticResource ContentFrameStyle}" 
                          myx:NavigationBinder.UriProperty="{Binding Path=NextView}" />
        <bxf:TriggerAction TargetControl="{Binding ElementName=ContentFrame}" MethodName="Navigated" TriggerEvent="Navigated"/>
        <bxf:TriggerAction TargetControl="{Binding ElementName=ContentFrame}" MethodName="NavigationFailed" TriggerEvent="NavigationFailed"/>
      </Grid>
    </Border>

    <Grid x:Name="NavigationGrid" Style="{StaticResource NavigationGridStyle}">

      <Border x:Name="BrandingBorder" Style="{StaticResource BrandingBorderStyle}">
        <StackPanel x:Name="BrandingStackPanel" Style="{StaticResource BrandingStackPanelStyle}">

          <ContentControl Style="{StaticResource LogoIcon}"/>
          <TextBlock x:Name="ApplicationNameTextBlock" Style="{StaticResource ApplicationNameStyle}" 
                               Text="Application Name"/>

        </StackPanel>
      </Border>

      <Border x:Name="LinksBorder" Style="{StaticResource LinksBorderStyle}">
        <ListBox Name="LinksListBox" Style="{StaticResource LinksListBoxStyle}" ItemsSource="{Binding Path=MenuItems}">
          <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
              <StackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
          </ListBox.ItemsPanel>
          <ListBox.ItemTemplate>
            <DataTemplate>
              <HyperlinkButton Style="{StaticResource LinkStyle}" NavigateUri="{Binding Path=Uri}" 
                               TargetName="ContentFrame" Content="{Binding Path=Name}"
                               myx:StateManager.VisualStateProperty="{Binding Path=State}"/>
            </DataTemplate>
          </ListBox.ItemTemplate>
        </ListBox>
      </Border>

    </Grid>
  </Grid>

</UserControl>